<template>
    <view class="content">
        <view class="nav">
            <view :class="{active : type == 0}" @click="chooseNav(0)">佣金方案</view>
            <view :class="{active : type == 1}" @click="chooseNav(1)">历史佣金</view>
        </view>
        <view class="wrapper">
            <view class="item" v-for="(item, index) in data.commission" :key="index">
                <view class="name">{{item.name}}</view>
                <view class="list">
                    <view class="list-l">方案类型</view>
                    <view class="list-r">{{item.type}}</view>
                </view>
                <!-- v-if="data.is_condition == 1" -->
                <templat v-if="item.condition && item.condition.length > 0">
                    <view v-for="(el, ind) in item.condition" :key="ind" class="u-p-b-15">
                        <view class="list">
                            <view class="list-l">跳点条件</view>
                            <view class="list-r">{{ el.condition }}</view>
                        </view>
                        <view class="list">
                            <view class="list-l">跳点规则</view>
                            <view class="list-r">{{ el.condition_price }}</view>
                        </view>
                    </view>
                </templat>
                <view class="list">
                    <view class="list-l">计算规则</view>
                    <view class="list-r">{{item.rules}}{{item.rules_type == 1 ? '元' : '%'}}/套</view>
                </view>
                <view class="list">
                    <view class="list-l">生效日期</view>
                    <view class="list-r">{{item.start_time}}</view>
                </view>
                <view class="list">
                    <view class="list-l">截止日期</view>
                    <view class="list-r">{{item.end_time}}</view>
                </view>
            </view>
            
            <view style="text-align: center;padding: 50upx 0;color: #999;font-size: 24rpx;" v-if="data.commission && data.commission.length == 0">暂无相关信息</view>
        </view>
        
        <!-- <view class="u-p-20" v-if="type == 1">
            <u-parse :html="data.notice"></u-parse>
            <view style="text-align: center;padding: 50upx 0;color: #999;font-size: 24rpx;" v-if="!data.notice">暂无相关信息</view>
        </view> -->
    </view>
</template>

<script>
    export default {
        data() {
            return {
                type: 0,
                id: '',
                data: {},
            };
        },
        onLoad(option) {
            this.id = option.id
            this.getData()
        },
        methods: {
            chooseNav(num) {
                this.type = num
                this.getData()
            },
            getData() {
                this.$ajax('commission_scheme', {
                    user_token: this.$getSync('userToken'),
                    id: this.id,//楼盘id
                    is_history: this.type,//0佣金方案 1历史佣金
                }).then(ret => {
                    if (ret.success == 1000) {
                        this.data = ret.detail
                    } else {
                        this.$toast(ret.msg);
                    }
                });
            },
        }
    };
</script>

<style lang="scss">
    
    
    page{
        background-color: #f5f5f5;
    }
    .nav{
        display: flex;
        justify-content: space-between;
        align-items: center;
        background-color: #fff;
        border-top: 2rpx solid #e6e6e6;
        margin-bottom: 16rpx;
    }
    .nav>view{
        width: calc(100vw / 2);
        text-align: center;
        padding: 25rpx;
        font-size: 26rpx;
    }
    .active{
        font-size: 28rpx;
        font-weight: bold;
        color: #00a1e9;
        border-bottom: 2rpx solid #00a1e9;
    }
    
    .wrapper{
        background-color: #fff;
        padding: 0 20rpx;
    }
    .item{
        padding: 35rpx 0;
        border-bottom: 2rpx solid #e6e6e6;
    }
    .item:last-child{
        border-bottom: none;
    }
    .name{
        font-size: 36rpx;
        font-weight: bold;
        padding-left: 20rpx;
        position: relative;
    }
    .name::after{
        display: block;
        content: '';
        width: 6rpx;
        height: 32rpx;
        background-color: #fe6155;
        position: absolute;
        top: 10rpx;
        left: 0;
    }
    .list{
        padding-top: 20rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .list-l{
        color: #747272;
        padding-right: 20rpx;
    }
    .list-r{
        flex: 1;
    }
    
</style>
